from collections import deque


def is_connected(g, s, t):
    q, visited = deque(), [False] * g.get_v_num()
    q.append(s)
    while q:
        curr = q.popleft()
        for adj in curr.get_adj():
            if not visited[adj.val]:
                if adj.val == t.val:
                    return True
                q.append(adj)
                visited[adj.val] = True
    return False


from instance import Graph1

graph1 = Graph1()
ans = is_connected(graph1.graph1, graph1.v0, graph1.v5)
print(ans)
